package com.qianfeng.smartdevices.controller;

import com.github.pagehelper.PageInfo;
import com.qianfeng.smartdevices.annotations.AopLogAnnotation;
import com.qianfeng.smartdevices.dto.R;
import com.qianfeng.smartdevices.pojo.LogData;
import com.qianfeng.smartdevices.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/logs")
public class LogController {

    private LogService logService;
    @Autowired
    public void setLogService(LogService logService) {
        this.logService = logService;
    }
    @GetMapping("/logs")
    @AopLogAnnotation("日志查询")
    public R findLogDataByPage(@RequestParam(defaultValue = "1") int page,@RequestParam(defaultValue = "10") int limit,String user,String msg) {
        PageInfo<LogData> logDataByPage = logService.findLogDataByPage(page, limit,user,msg);
        return R.setOK(logDataByPage);
    }
    @PutMapping("/logs")
    @AopLogAnnotation("日志更新")
    public R updateLogData(LogData logData) {
        logService.updateLogData(logData);
        return R.setOK();
    }

    @DeleteMapping("/logs")
    @AopLogAnnotation("日志删除")
    public R deleteLogData(Long[] ids){
        logService.deleteLogData(ids);
        return R.setOK();
    }
}
